import request from '@/utils/request'

// 获取员工列表
export const reqGetEmployees = params => request({
  url: '/sys/user',
  params
})

// 导入员工的请求
export const reqExportExcel = () => request({
  url: '/sys/user/export',
  // 设置类型
  responseType: 'blob'
})

// 封装下载模板
export const reqGetTemplate = () => request({
  url: '/sys/user/import/template',
  responseType: 'blob'
})

// 上传文件
export const reqUploadExcel = data => request({
  method: 'post',
  url: '/sys/user/import',
  data
})

// 删除员工的接口
export const reqDelEmployee = (id) => request({
  method: 'delete',
  url: `/sys/user/${id}`
})

// 新增员工的请求
export const reqAddEmployee = (data) => request({
  method: 'post',
  url: '/sys/user',
  data
})

// 查看员工的请求
export const reqGetDetail = (id) => request({
  url: `/sys/user/${id}`

})

// 修改员工的信息
export const reqUpdateDetail = (data) => request({
  method: 'put',
  url: `/sys/user/${data.id}`,
  data
})

// 为用户分配角色请求
export const reqAssignRoles = (id, roleIds) => request({
  method: 'put',
  url: '/sys/user/assignRoles',
  data: {
    id,
    roleIds
  }
})

